Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amendment fixFrozenLPTokenTransfer: Prohibit transfer of LPToken when an asset is frozen #5227

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

shawnxie999
Copy link
Collaborator

@shawnxie999 shawnxie999 commented Dec 18, 2024

High Level Overview of Change

New Definition

A holder's LPToken is now considered "frozen" if at least one of the two assets in the associated liquidity pool is regularly frozen.

Background

Prior to this amendment, a blacklisted account that owns frozen LPTokens could still transfer them through mechanisms such as Payments, Checks, Offers, or NFTs. This loophole allowed the recipient of these LPTokens to redeem or withdraw the underlying assets of the pool, bypassing the restrictions that should have applied to the blacklisted account. This behavior undermines the freezing mechanism's integrity and creates inconsistencies in asset control.

Note: this amendment only works with the existing regular freeze, and has no correlation with deep-freeze

Example

  1. Alice deposits XRP and USD into an AMM pool.
  2. The USD issuer freezes Alice's USD trustline.
  3. Alice transfers her LPToken to Bob (although Alice cannot transfer USD directly, she can still transfer the LPToken).
  4. Bob redeems USD using the received LPToken, effectively bypassing the freezing restrictions imposed on Alice.

Amendment changes

This amendment ensures that frozen LPTokens cannot be transferred. Below are the changes to specific transaction types:

Payments

  • A blacklisted account can no longer send frozen LPTokens through direct payment.
  • Offers attempting to sell frozen LPTokens can no longer be consumed on the DEX.

OfferCreate

  • Accounts are prohibited from creating offers that attempt to sell frozen LPTokens.

CheckCash

  • Cashing a check fails if it attempts to cash a frozen LPToken from the sender.

NFTokenCreateOffer

  • Buyers are prohibited from creating buy offers involving frozen LPTokens.

NFTokenAcceptOffer

  • Buyers cannot accept a sell offer if the offer requires the use of frozen LPTokens as payment.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

@shawnxie999 shawnxie999 changed the title Lptoken freeze WIP Lptoken freeze Dec 18, 2024
@shawnxie999 shawnxie999 marked this pull request as ready for review December 18, 2024 21:40
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 93.87755% with 3 lines in your changes missing coverage. Please review.

Project coverage is 77.9%. Comparing base (0324764) to head (caa857c).

Files with missing lines Patch % Lines
src/xrpld/app/misc/detail/AMMUtils.cpp 93.3% 1 Missing ⚠️
src/xrpld/app/paths/detail/StepChecks.h 90.9% 1 Missing ⚠️
src/xrpld/ledger/detail/View.cpp 95.0% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5227   +/-   ##
=======================================
  Coverage     77.9%   77.9%           
=======================================
  Files          783     783           
  Lines        66707   66750   +43     
  Branches      8118    8120    +2     
=======================================
+ Hits         51953   51993   +40     
- Misses       14754   14757    +3     
Files with missing lines Coverage Δ
include/xrpl/protocol/Feature.h 100.0% <ø> (ø)
src/xrpld/app/paths/detail/DirectStep.cpp 82.5% <100.0%> (ø)
src/xrpld/ledger/View.h 100.0% <ø> (ø)
src/xrpld/app/misc/detail/AMMUtils.cpp 98.9% <93.3%> (-0.5%) ⬇️
src/xrpld/app/paths/detail/StepChecks.h 97.1% <90.9%> (-2.9%) ⬇️
src/xrpld/ledger/detail/View.cpp 91.2% <95.0%> (+0.1%) ⬆️

Impacted file tree graph

@shawnxie999 shawnxie999 changed the title WIP Lptoken freeze Amendment fixFrozenLPTokenTransfer: Prohibit transfer of LPToken when an asset is frozen Jan 6, 2025
@shawnxie999 shawnxie999 requested review from gregtatcam, yinyiqian1 and vvysokikh1 and removed request for gregtatcam January 7, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant